home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Compilers⁄Interps / C_Interp / test.s < prev   
Encoding:
Text File  |  1992-05-01  |  769 b   |  55 lines  |  [TEXT/KAHL]

  1. char *p;
  2. int procs[3];
  3.  
  4. main()
  5. {
  6. int i;
  7. char s[30];
  8. int x, *xp;
  9.  
  10. display("Display Test 1\n");
  11. display("Display Test %i\n", 2);
  12. display("Display Test %s\n", "Three");
  13. display("DT %05i\n",4);
  14. display("DT >%5i\n",5);
  15. sprintf(s, "%s %i", "Test String Arg", 67);
  16. printf("DT %s, %-4d.\n", s, 67);
  17.  
  18.     procs[0] = silly;
  19.     procs[1] = not_silly;
  20.     procs[2] = puts;
  21.     strcpy(s,"H");
  22.     puts("Testing");
  23.     x = 4;
  24.     change_int(&x);
  25.     puts("x:");
  26.     puts(itoa(x));
  27.     puts(itoa(p[0]));
  28.     puts(itoa(p[1]));
  29.     puts(p);
  30.     if (p[0]) puts("P[0] isn't zero");
  31.     
  32.     for (i=4;i<6;i++)
  33.         (procs[i-4])(i);
  34.     (procs[2])("All done");
  35. }
  36.  
  37. change_int(int *x)
  38. {
  39.     *x = 0x43454700;
  40.     p=x;
  41. }
  42.  
  43. silly(int x)
  44. {
  45. int i;
  46.   for (i=0;i<x;i++) {
  47.       puts("Silly");
  48.   }
  49. }
  50.  
  51. not_silly(int x)
  52. {
  53.   puts("Not Silly");
  54.   puts(itoa(x*x));
  55. }